main
Sub Main
	Dim doc
	Set doc = Application.ActiveDocument
	Dim objs
	Set objs = doc.GetObjects(ppcbObjectTypeComponent, "*",1)
	If objs.Count=0 Then 
		Exit Sub
	end if
	Dim filename,filepath
	filename = InputBox("filename =?",filename,"0")
	filename= Trim(filename)

	If filename<>"" Then 
	
		Dim tstr,ostr
		ostr = ""	
		Dim obj
		For Each obj In objs
			tstr = obj.Name & Chr(9) & obj.PositionX & Chr(9) & obj.PositionY
			If ostr<>"" Then 
				ostr = ostr & chr(13) & chr(10)
			end if
			ostr = ostr & tstr
		Next

		Dim EnvRoot,CacheFolder
		EnvRoot =GetEnvRoot
		CacheFolder = EnvRoot & "\cache\xy\"
		filepath = CacheFolder & filename & ".txt"
	
		FSO_OnWriteToFile filepath,ostr
		MsgBox "done"
	end if
End Sub

Function GetEnvRoot
	dim EnvRoot 
	Dim ws,varName,regPath
	Set ws = CreateObject("WScript.Shell")
	varName = "PADS_SHORTCUT_ROOT"
	regPath ="HKEY_CURRENT_USER\Software\MyApp\PADS\" & varName
	EnvRoot = ws.RegRead(regPath)
	set ws = nothing
	GetEnvRoot = EnvRoot
End Function

Sub FSO_OnWriteToFile(filepath,ostr)
	Dim fso,fw
	Set fso = CreateObject("scripting.filesystemobject")
	Set fw = fso.CreateTextFile(filepath,True)
	fw.Write(ostr)
	fw.close
	Set fw = Nothing	
	Set fso = Nothing
End Sub
